$.ajax({
	"url":"/upload_file/",
	"error":errorAjax,
	"complete":stop_load_pic,
	"beforeSend":start_load_pic,
	"dataType":"jsonp",
	"success":function(data){
		if(responseCheck(data)){
			var tab=document.getElementById("tab")
			for(var i=0;i<data.content.length;i++){
				var tr=document.createElement("tr")

				var td=document.createElement("td")
				td.textContent=data.content[i].username
				tr.appendChild(td)


				var td=document.createElement("td")
				td.textContent=data.content[i].date
				tr.appendChild(td)

				var td=document.createElement("td")
				td.textContent=data.content[i].filename
				tr.appendChild(td)

				var td=document.createElement("td")
				var a=document.createElement("a")
				a.setAttribute("href",data.content[i].path)
				a.textContent="下载"
				td.appendChild(a)

				var a=document.createElement("a")
				a.setAttribute("target","_blank")
				a.style.marginLeft="10px"
				a.setAttribute("href","show.html?table=H&fileid="+data.content[i].id+"&filename="+data.content[i].filename+"&date="+data.content[i].date+"&username="+data.content[i].username)
				a.textContent="查看"
				td.appendChild(a)

				var a=document.createElement("a")
				a.setAttribute("target","_blank")
				a.style.marginLeft="10px"
				a.setAttribute("href","report.html?username="+data.content[i].username+"&date="+data.content[i].date+"&folder_amount="+data.content[i].folder_amount+"&file_amount="+data.content[i].file_amount+"&record_amount="+data.content[i].record_amount+"&filename="+data.content[i].filename)
				a.textContent="报告"
				td.appendChild(a)


				tr.appendChild(td)

				tab.appendChild(tr)


			}
		}
	}
})
document.getElementById("upload_file").onclick=function(){
	document.getElementById("file").click()
}
document.getElementById("file").onchange=function(){
	var file=$(this).prop("files")[0]
	console.log($("#file").val())
	if ($("#file").val()===""){
		return false;
	}
	var data=new FormData()
	data.append("file",file)
	jQuery.ajax({
		"url":"/upload_file/",
		"type":"POST",
		"data":data,
		"processData":false,
                "contentType": false,
		"error":errorAjax,
		"complete":stop_load_pic,
		"beforeSend":start_load_pic,
                "cache": false,
		"success":function(data){
			if(responseCheck(data)){
				alert("已上传！")
				window.location.reload()
			}
			else{
				$("#file").val("")
			}
		}
	})
	
}
